﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.TradeRumor
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem
{
  public class TradeRumor
  {
    [SaveableField(0)]
    public readonly Settlement Settlement;
    [SaveableField(1)]
    public readonly ItemObject ItemCategory;
    [SaveableField(2)]
    public readonly int BuyPrice;
    [SaveableField(3)]
    public readonly int SellPrice;

    internal static void AutoGeneratedStaticCollectObjectsTradeRumor(
      object o,
      List<object> collectedObjects)
    {
      ((TradeRumor) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected virtual void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      collectedObjects.Add((object) this.Settlement);
      collectedObjects.Add((object) this.ItemCategory);
      CampaignTime.AutoGeneratedStaticCollectObjectsCampaignTime((object) this.RumorEndTime, collectedObjects);
    }

    internal static object AutoGeneratedGetMemberValueRumorEndTime(object o)
    {
      return (object) ((TradeRumor) o).RumorEndTime;
    }

    internal static object AutoGeneratedGetMemberValueSettlement(object o)
    {
      return (object) ((TradeRumor) o).Settlement;
    }

    internal static object AutoGeneratedGetMemberValueItemCategory(object o)
    {
      return (object) ((TradeRumor) o).ItemCategory;
    }

    internal static object AutoGeneratedGetMemberValueBuyPrice(object o)
    {
      return (object) ((TradeRumor) o).BuyPrice;
    }

    internal static object AutoGeneratedGetMemberValueSellPrice(object o)
    {
      return (object) ((TradeRumor) o).SellPrice;
    }

    [SaveableProperty(4)]
    public CampaignTime RumorEndTime { get; private set; }

    public bool IsCompatable(ItemObject item) => item == this.ItemCategory;

    public bool IsExpired() => this.RumorEndTime.IsPast;

    public TradeRumor(
      Settlement settlement,
      ItemObject itemCategory,
      int buyPrice,
      int sellPrice,
      int rumorLife)
    {
      this.Settlement = settlement;
      this.ItemCategory = itemCategory;
      this.BuyPrice = buyPrice;
      this.SellPrice = sellPrice;
      this.RumorEndTime = CampaignTime.DaysFromNow((float) rumorLife);
    }
  }
}
